﻿using System;
using System.Windows.Forms;

namespace Texpro
{
    class PCMSG
    {

        public static String m_text;
        public static String m_caption;
        public static MessageBoxButtons m_buttons;
        public static MessageBoxIcon m_icon;
        public static MessageBoxDefaultButton m_default;
        public static DialogResult m_result;

        //PCMSG.Show("text", "caption", MessageBoxButtons.OK,  MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);

        public static DialogResult ShowError(Exception p_error)
        {
            m_text = p_error.Message.ToString();
            m_caption = "Error";
            m_icon = MessageBoxIcon.Error;
            m_buttons = MessageBoxButtons.OK;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }

        public static DialogResult ShowError(String p_text)
        {
            m_text = p_text.ToString();
            m_caption = "Error";
            m_icon = MessageBoxIcon.Error;
            m_buttons = MessageBoxButtons.OK;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }
        
        public static DialogResult Show(String p_text)
        {
            m_text = p_text.ToString();
            m_caption = "Information";
            m_icon = MessageBoxIcon.Information;
            m_buttons = MessageBoxButtons.OK;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = MessageBoxIcon.Information;
            m_buttons = MessageBoxButtons.OK;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption, MessageBoxIcon p_icon)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = p_icon;
            m_buttons = MessageBoxButtons.OK;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption, MessageBoxIcon p_icon, MessageBoxButtons p_buttons)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = p_icon;
            m_buttons = p_buttons;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption, MessageBoxButtons p_buttons, MessageBoxIcon p_icon)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = p_icon;
            m_buttons = p_buttons;
            m_default = MessageBoxDefaultButton.Button1;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption, MessageBoxIcon p_icon, MessageBoxButtons p_buttons, MessageBoxDefaultButton p_default)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = p_icon;
            m_buttons = p_buttons;
            m_default = p_default;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption, MessageBoxButtons p_buttons, MessageBoxIcon p_icon, MessageBoxDefaultButton p_default)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = p_icon;
            m_buttons = p_buttons;
            m_default = p_default;
            return ShowForm();
        }

        public static DialogResult Show(String p_text, String p_caption, MessageBoxButtons p_buttons, MessageBoxDefaultButton p_default)
        {
            m_text = p_text.ToString();
            m_caption = p_caption.ToString();
            m_icon = MessageBoxIcon.Information;
            m_buttons = p_buttons;
            m_default = p_default;
            return ShowForm();
        }

        private static DialogResult ShowForm()
        {     
            if (m_text.Length > 0)
            {
                FMMN106 mf = new FMMN106();
                mf.ShowDialog();
                mf.Dispose();
            }
            m_text = String.Empty;
            m_caption = String.Empty;
            m_icon = MessageBoxIcon.Information;
            m_buttons = MessageBoxButtons.OK;
            m_default = MessageBoxDefaultButton.Button1;
            return m_result;
        }
    }
}
